<template>
	<view class="radius margin-top-sm maoboli padding-sm">
		<view>
			<view style="display: flex;">
				<view style=" position: relative;">

					<image :src="data.imgList!=null&&data.imgList.length>0?data.imgList[0]:'/static/images/未上传门店照片.png'"
						style="width: 180rpx;height: 180rpx;" class="radius" @click="previewImage(data.imgList)">
					</image>
					<view class="imgTap maoboli">
						多图
					</view>
				</view>
				<view style="flex: 2;" class="margin-left-sm" @click="select">
					<view class="font-title " style="font-size: 30rpx;">
						{{data.title}}
					</view>
					<view style="font-size: 26rpx;margin-top: 10rpx;color: #999">
						<view class="mine-actions grid col-3 ">
							<view class="action-item " v-for="item in data.priceInfo">
								<view class="font-content">
									<text>{{item.hour}}小时{{item.price}}元</text>
								</view>
							</view>
						</view>

					</view>
					<view style="font-size: 20rpx;margin-top: 10rpx;color: #999;  flex-wrap: wrap;display: flex;">
						<text class="mendianTap font-content" v-for="item in data.tag">{{item}}</text>
					</view>
				</view>
			</view>
			<!-- 时间点 -->
			<view style="display: flex;margin-top: 10rpx;" @click="select">
				<view v-for="(item,index) in tileNodeList" style="flex: 1;">
					<view style="font-size: 10px;">
						<view :class="{'shijianno':data.timeNode.includes(item),'shijiandian':true} "></view>
						<view class="juzhong font-content"> {{item==0&&index!=0?'次':item}}</view>
					</view>
				</view>
			</view>

			<view style="display: flex; margin-top: 10rpx;">
				<view style="flex: 1;font-size: 10px;">
					<view style="display: flex;">
						<view>
							<view class="shijianno shijiandian"></view>
							<view class="juzhong font-content">使用中</view>
						</view>
						<view class="margin-left-lg">
							<view class="shijiandian"></view>
							<view class="juzhong font-content">可预约</view>
						</view>
					</view>

				</view>
				<view style="flex: 1;">

				</view>
				<view style="flex: 1;">
					<!-- <button class="login-btn cu-btn block bg-pink sm round">预约</button> -->
				</view>
			</view>

		</view>


	</view>
</template>

<script>
	import {
		compareDates,
		formatDate
	} from '../../utils/validate';
	export default {
		name: "roomMJ",
		props: {
			data: {
				type: Object,
				default: {}
			},
		},
		data() {
			return {
				tileNodeList: [

				]
			};
		},
		created() {
			this.getHoursFromNow()
		},
		methods: {
			/**
			 * 打开预约弹框
			 */
			getHoursFromNow() {
				let now = new Date();
				let hoursFrom21 = now.getHours(); // 获取当前小时数
				let hours = [];

				//如果所选日期不是今天 那时间段就是24小时
				if (compareDates(this.data.date, formatDate(new Date())) != 0) {
					hoursFrom21 = 0
				}
				for (let i = hoursFrom21; i < hoursFrom21 + 24; i++) {
					// 将小时数添加到数组中，如果超过24小时，则从0开始
					let a = i % 24
					if (a == 0) {
						// a = '次'
					}
					hours.push(a);
				}

				this.tileNodeList = hours;
			},
			/**
			 * 预览图片
			 */
			previewImage(imgList) {
				this.$emit("showImg", imgList)
			},
			select(imgList) {
				this.$emit("select", this.data)
			}


		}
	}
</script>

<style lang="scss">
	.mendianTap {
		margin-top: 5rpx;
		padding: 0px 2px;
		border: solid $uni-color-success-sen 1px;
		margin-right: 10rpx;
		margin-top: 5rpx;
		border-radius: 5px;
		color: $uni-color-success-sen;
	}

	.imgTap {
		position: absolute;
		padding: 0px 2px;
		color: #999;
		top: 5rpx;
		font-size: 10px;
		border-radius: 10rpx;
		left: 5rpx;
	}

	.shijiandian {
		height: 8rpx;
		background-color: #ccc;
		margin: 0px 2px;
		border-radius: 2px;
	}

	.shijianno {
		background-color: $uni-color-primary;
	}
</style>